package com.game.modular.gameCore.cultivate.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

/**
 * 账户相关配置(CoreAccountConfig)表实体类
 *
 * @author cxy
 * @since 2024-08-07 10:00:19
 */
@ApiModel("账户相关配置")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("serial")
public class CoreAccountConfig extends Model<CoreAccountConfig> {// swagger2,mybatis-plus
    ///////////////////////////////////////////////////////////////////////////////////////////////////////// 生成实体字段
    @TableId(type = IdType.AUTO)
    @ApiModelProperty("全局配置id")
    private Long id;
    
    @ApiModelProperty("全局配置名字")
    private String configName;
    
    @ApiModelProperty("获取的物品")
    private String prop;
    
    @ApiModelProperty("获取的英雄")
    private String hero;
    
    @ApiModelProperty("战法")
    private String skills;
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////// 序列化版本号
    @TableField(exist = false)
    private static final long serialVersionUID = 656680843918510902L;
    /////////////////////////////////////////////////////////////////////////////////////////////////////////// 获取主键值
    @Override
    public Serializable pkVal() {
        return this.id;
    }

    @TableField(exist = false)
    private Map<Long,Long> propInfo;

    @TableField(exist = false)
    private Map<Long,Long> heroInfo;

    @TableField(exist = false)
    private Map<Long,Long> skillsInfo;

    public CoreAccountConfig init() {
        propInfo = new HashMap<>();
        for (String propString : prop.split(",")) {
            String[] split = propString.split("&");
            propInfo.put(Long.valueOf(split[0]),Long.valueOf(split[1]));
        }
        heroInfo = new HashMap<>();
        for (String heroString : hero.split(",")) {
            String[] split = heroString.split("&");
            heroInfo.put(Long.valueOf(split[0]),Long.valueOf(split[1]));
        }
        skillsInfo = new HashMap<>();
        for (String skillsString : skills.split(",")) {
            String[] split = skillsString.split("&");
            skillsInfo.put(Long.valueOf(split[0]),Long.valueOf(split[1]));
        }
        return this;
    }
}

